package com.zking.service.impl.ypf;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zking.dao.domain.User;
import com.zking.dao.mapper.ypf.ResourcesMapper;
import com.zking.dao.mapper.ypf.UserMapper;
import com.zking.service.ypf.OverUserService;

@Service
public class OverUserServiceImpl implements OverUserService{
	@Autowired
	UserMapper userMapper;
	
	@Autowired 
	ResourcesMapper resourcesMapper; 
	
	
//	@Override
//	public int Useradd(User user) {
//		int i=userMapper.Useradd(user);
//		return i;
//	}
//
//	@Override
//	public int companyuserAdd(User user) {
//		int i=userMapper.companyuserAdd(user);
//		return i;
//	}

	@Override
	public User getUser(User user) {
		User user2=userMapper.getUser(user);
		return user2;
	}

	@Override
	public Set<String> findPermissionsByUserId(int id) {
		Set<String> permissions=resourcesMapper.findRoleNameByUserId(id);
		Set<String> result = new HashSet<>();
		for (String permission : permissions) {
			if (StringUtils.isBlank(permission)) {
				continue;
			}
			permission = StringUtils.trim(permission);
			result.add(permission);
		}
		return result;
	}

	@Override
	public int addUser(User user) {
		int i=userMapper.Useradd(user);
		return i;
	}

	@Override
	public List<User> overUser(User user) {
		List<User> listUser=userMapper.overUser(user);
		return listUser;
	}
	
	

}
